#include"Common.h"

class Mutex
{
public:
    Mutex(pthread_mutex_t* pmtx)
        :_pmtx(pmtx)
    {}
    void lock()
    {
        pthread_mutex_lock(_pmtx);
    }
    void unlock()
    {
        pthread_mutex_unlock(_pmtx);
    }
private:
    pthread_mutex_t* _pmtx;
};

class MutexGuard
{
public:
    MutexGuard(pthread_mutex_t* pmtx)
        :_pmtx(pmtx)
    {
        _pmtx.lock();
    }
    ~MutexGuard()
    {
        _pmtx.unlock();
    }
private:
    Mutex _pmtx;
};